import 'dart:io';

void main() async {
  print('🔧 修复Word模型参数...');
  
  final filesToFix = [
    'lib/data/esperanto_mega_vocabulary.dart',
    'lib/data/esperanto_vocabulary_batch2.dart',
  ];
  
  for (final filePath in filesToFix) {
    print('修复文件: $filePath');
    await fixWordParameters(filePath);
  }
  
  print('✅ 修复完成！');
}

Future<void> fixWordParameters(String filePath) async {
  final file = File(filePath);
  if (!await file.exists()) {
    print('❌ 文件不存在: $filePath');
    return;
  }
  
  String content = await file.readAsString();
  
  // 修复参数
  content = content
    // 将 example: 改为 examples: [
    .replaceAllMapped(
      RegExp(r"example: '([^']+)'"),
      (match) => "examples: ['${match.group(1)}']"
    )
    // 将 difficulty: 'beginner' 改为 difficulty: 1
    .replaceAll("difficulty: 'beginner'", "difficulty: 1")
    // 将 difficulty: 'intermediate' 改为 difficulty: 2
    .replaceAll("difficulty: 'intermediate'", "difficulty: 2")
    // 将 difficulty: 'advanced' 改为 difficulty: 3
    .replaceAll("difficulty: 'advanced'", "difficulty: 3")
    // 修复拼写错误
    .replaceAll("defficulty: 'intermediate'", "difficulty: 2");
  
  await file.writeAsString(content);
  print('✅ 已修复: $filePath');
} 